package cn.zbacm.api.application.repository;

import cn.zbacm.api.application.entity.ApplicationRole;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ApplicationRoleRepository
        extends PagingAndSortingRepository<ApplicationRole, Integer> {
  @EntityGraph(attributePaths = "application")
  List<ApplicationRole> findWithApplicationByRoleIdIn(List<Integer> roleIds);

  List<ApplicationRole> findByRoleIdIn(List<Integer> roleIds);

  List<ApplicationRole> findByApplicationIdInAndRoleIdIn(
          List<Integer> appIds, List<Integer> roleIds);
}
